/**
 * Created by Administrator on 2017/6/14.
 */
//深度克隆对象
function cloneFun(obj){
    if(!obj||"object" != typeof obj){
        return null;
    }
    var result = (obj instanceof Array)?[]:{};
    for(var i in obj){
        result[i] = ("object" != typeof obj[i])?obj[i]:cloneFun(obj[i]);
    }
    return result;
}

//日志兼容性
function log(msg){
    if(window.console && console.log){
        console.log(msg);
    }
}

//jquery1.8查询控件绑定的事件
$._data(domObj,'events');
//jquery1.8之前查询控件绑定的事件
$obj.data('events');

// 传入"rgb(117, 134, 151)"返回"#758697"
function colorRGBtoHex(color) {
    var rgb = color.split(',');
    var r = parseInt(rgb[0].split('(')[1]);
    var g = parseInt(rgb[1]);
    var b = parseInt(rgb[2].split(')')[0]);
    var hex = "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
    return hex;
}



// html5实现页面文件下载
function downloadFile(fileName, content, contentType) {
    var eleLink = document.createElement('a');
    eleLink.download = fileName;
    eleLink.style.display = 'none';
    // 字符内容转变成blob地址
    var blob = new Blob([content],
        {type : contentType?content:'text/plain'});
    eleLink.href = URL.createObjectURL(blob);
    // 触发点击
    document.body.appendChild(eleLink);
    eleLink.click();
    // 然后移除
    document.body.removeChild(eleLink);
}